package com.mall.common.utils;

import lombok.Data;
import java.io.Serializable;

@Data
public class AjaxResult implements Serializable {
    private static final long serialVersionUID = 1L;

    private Integer code;
    private String message;
    private Object data;

    public static AjaxResult success() {
        return success("操作成功");
    }

    public static AjaxResult success(String message) {
        return success(message, null);
    }

    public static AjaxResult success(Object data) {
        return success("操作成功", data);
    }

    public static AjaxResult success(String message, Object data) {
        AjaxResult result = new AjaxResult();
        result.setCode(200);
        result.setMessage(message);
        result.setData(data);
        return result;
    }

    public static AjaxResult error() {
        return error("操作失败");
    }

    public static AjaxResult error(String message) {
        return error(500, message);
    }

    public static AjaxResult error(Integer code, String message) {
        AjaxResult result = new AjaxResult();
        result.setCode(code);
        result.setMessage(message);
        return result;
    }
}